package linwen.wang.commom;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName ReturnVO
 * @Description return VO
 * @Author zero
 * @Date 2022/3/2 下午10:42
 * @Version V1.0
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ReturnVO<T> {
    private T data;
    private Integer code;
    private String msg;

    public static ReturnVO buildEmptyReturnVO(String message){
        ReturnVO returnVO = new ReturnVO();
        returnVO.setCode(200);
        returnVO.setMsg(message);
        returnVO.setData(null);
        return returnVO;
    }

    public static ReturnVO buildErrorReturnVO(String message,Object data){
        ReturnVO returnVO = new ReturnVO();
        returnVO.setCode(400);
        returnVO.setMsg(message);
        returnVO.setData(data);
        return returnVO;
    }

    public static ReturnVO buildReturnVO(Object data){
        ReturnVO returnVO = new ReturnVO();
        returnVO.setCode(200);
        returnVO.setMsg("请求成功！！");
        returnVO.setData(data);
        return returnVO;
    }

}
